// pages/userInfo/userInfo.js
var app = getApp();
const getdata = require("../../tool/GetDate.js")
var currentPage = 0;
var listData = [];
var paramData = [];
var districtID = 0;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userList: [],
    code: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    currentPage = 1;
    listData = [];
    districtID = app.globalData.myUserData.districtID;
    this.getUserInfo(districtID);

    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  getUserInfo: function (districtID) {
    let that = this;
    getdata.getdata({
      url: "gbt/UserVerify/UserList/" + currentPage + "/",
      data: districtID,
      success: function (res) {
        console.log(res.root);
        if (res.root) {
          let array = res.root.data;
          let userItem = {};
          for (let index = 0; index < array.length; index++) {
            userItem.title = array[index].name;
            userItem.hallName = array[index].number;
            userItem.mealDateTitle = "手机号码";
            userItem.mealDateValue = array[index].mobile;
            userItem.mealTitle = "昵称";
            userItem.mealValue = array[index].nickName;
            listData.push(userItem);
            userItem = {};
          }
          that.setData({
            userList: listData,
          });
        }
      },
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    currentPage++;
    this.getUserInfo(districtID);
  },

  // /**
  //  * 用户点击右上角分享
  //  */
  // onShareAppMessage: function () {

  // },

  onDef:function(e){
    currentPage = 1;
    listData = [];
    districtID = app.globalData.myUserData.districtID;
    this.getUserInfo(districtID);
  },

  onConfirm: function (e) {
    listData = [];
    currentPage = 1;
    districtID = e.detail;
    this.getUserInfo(districtID);
  },
})